using System;
using Core.Event;
using Game;
using UnityEngine;
using UnityEngine.UI;

public class WeaponArea : MonoBehaviour {
    public Text WeaponName;
    public Text WeaponDesp;
    public Button BtnNextWeapon;

    private void Start() {
        BtnNextWeapon.onClick.AddListener(() => {
            var equip = PlayerManager.Ins.CurPlayer.EquipModule; 
            equip.UseWeapon(equip.CurIndex + 1);
            GameEventMgr.Ins.PushEvent(GameEventID.SwitchWeapon);
            Refresh();
        });
    }

    public void Refresh() {
        var weapon = PlayerManager.Ins.CurPlayer.EquipModule.GetWeapon();
        var data = weapon.Data;
        WeaponName.text = data.Name;
        WeaponDesp.text = data.PrefabPath;
    }
}
